package com.itxiaowu.service.impl;

import com.alibaba.dubbo.config.annotation.Service;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.itxiaowu.dao.PermissionDao;
import com.itxiaowu.entity.PageResult;
import com.itxiaowu.pojo.Permission;
import com.itxiaowu.service.PermissionService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;

@Service(interfaceClass = PermissionService.class)
@Transactional
public class PermissionServiceImpl implements PermissionService{

    @Autowired
    private PermissionDao permissionDao;

    //获取所有用户数据分页显示
    @Override
    public PageResult findPage(Integer currentPage, Integer pageSize, String queryString) {
        PageHelper.startPage(currentPage, pageSize);
        Page<Permission> page = permissionDao.selectByCondition(queryString);
        return new PageResult(page.getTotal(),page.getResult());
    }
    //添加权限信息
    @Override
    public void add(Permission permission) {
        permissionDao.add(permission);
    }
    //根据id查询权限信息
    @Override
    public Permission findFormDataById(Integer id) {
        Permission permission=permissionDao.findFormDataById(id);
        return permission;
    }
    //根据id删除权限
    @Override
    public void deleteById(Integer id) {
        permissionDao.delteById(id);
    }

    @Override
    public void edit(Permission permission) {
        permissionDao.edit(permission);
    }
}
